[USER (data scientist)]: Hey Tapilot, I have this dataset of tennis matches, and I want to update the odds for each match based on the new competitors' performance. Can you help me figure out the head-to-head win rates for each player? Please define a function to calculate the head-to-head win rates for all unique player pairings in the ATP tennis dataset.
My template of code snippet is:

---BEGIN CODE TEMPLATE---

import pandas as pd
import numpy as np
import pickle

atp_tennis = pd.read_csv('atp_tennis.csv')

# YOUR SOLUTION BEGIN:
<code1>
[COMPLETE YOUR CODE] 
</code1>
# YOUR SOLUTION END

---END CODE TEMPLATE---

[YOU (AI assistant)]: Absolutely! Here's a function that calculates the head-to-head win rates for each player in your dataset: 
'''
import pandas as pd
import numpy as np
import pickle

atp_tennis = pd.read_csv('atp_tennis.csv')

# YOUR SOLUTION BEGIN:
